do
  function setType(parent)
    parent:setType("gunner");
  end
  
  function update(parent)
  
  
    
    local xMove = 0;
    local yMove = 0;
    local cur = parent:getCuriousity()/2;
    cur = parent:diceRoll(cur);
    local dir = parent:diceRoll(8);
    
    
    local itr = parent:getComrades():iterator();
    while itr:hasNext() do
      local roll = parent:diceRoll(3);
      local element = itr:next();
      if roll == 1 then
        if element:getY() < parent:getY() then
          dir = 3;
        elseif element:getY() > parent:getY() then
          dir = 7;
        elseif element:getX() < parent:getX() then
          dir = 1;
        else
          if element:getX() > parent:getX() then
            dir = 5;
          end
        end
      end
    end
    
    
    local elapsed = parent:getElapsedAI();
    if elapsed < 16 then
      if parent:isRedTeam() then
        dir = 8;
      else
        dir = 4;
      end
    else
        if elapsed < 300 then
          local px = parent:getX();
          local py = parent:getY();
          local loc = parent:getClosestUndiscoveredLocation(px,py);
          local xx = loc:getX();
          local yy = loc:getY();
          local run1 = parent:diceRoll(2);
          if run1 == 1 then
            parent:move(xx,yy,cur);
            return
          else 
            parent:run(xx,yy,cur);
            return
        end
      end
    end
   
    
    
    
    if dir == 1 then
      xMove=-200;
    elseif dir == 2 then
      xMove=-100;
      yMove=-100;
    elseif dir == 3 then
      yMove=-200;
    elseif dir == 4 then
      xMove = 100;
      yMove = -100;
    elseif dir == 5 then
      xMove = 200;
    elseif dir == 6 then
      xMove = 100;
      yMove = 100;
    elseif dir == 7 then
      yMove = 200;
    else
      xMove=-100;
      yMove = 100;
    end
    
    
    local run = parent:diceRoll(2);
    cur = cur/2;
    
    if run == 1 then
      local x = parent:getX()+xMove;
      local y = parent:getY()+yMove;
      parent:move(x,y,cur);
    else 
      local x = parent:getX()+xMove*2;
      local y = parent:getY()+yMove*2;
      parent:run(x,y,cur);
    end
  end
  
  setType();
  update();
end